using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace C4F.DevKit.RSS.ScreenSaverWPF
{
    public partial class OptionsWindow : System.Windows.Window
    {
        public OptionsWindow()
        {
            InitializeComponent();

            // Initialize the text box for setting the time interval from the user settings.
            pauseTextBox.Text = SettingsWrapper.FadePauseInterval.ToString();
        }

        void OnOk(object sender, RoutedEventArgs e)
        {
            // Parse the text box for input.
            int newValue = -1;
            bool succ = int.TryParse(pauseTextBox.Text, out newValue);
           
            if ((newValue <= 0) || (!succ))
            {
                // If the input was not what was expected, display an error message
                // for the user.
                MessageBox.Show(ResourcesWrapper.ValueGreaterThanZeroText2,
                    ResourcesWrapper.InvalidInputText,
                    MessageBoxButton.OK, MessageBoxImage.Asterisk);
            }
            else
            {
                // Save settings and close this window.
                SettingsWrapper.FadePauseInterval = newValue;
                this.Close();
            }
        }

        void OnCancel(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}